package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.admin.statement.vo.StatementVo;
import com.cskaoyan.service.admin.StatementService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Name : StatController.java
 * @Time : 2021/8/13 14:30
 * @Author : creamycandy
 * @Software : IntelliJ IDEA
 */
@RestController
@RequestMapping("admin/stat")
public class StatementController {


    @Autowired
    StatementService statementService;

    @RequiresPermissions(value = {"*", "admin:stat:order"}, logical = Logical.OR)
    @RequestMapping("order")
    public BaseRespVo getOrdersNum(){
        StatementVo orders = statementService.getOrders();
        return BaseRespVo.ok(orders);
    }

    @RequiresPermissions(value = {"*", "admin:stat:user"}, logical = Logical.OR)
    @RequestMapping("user")
    public BaseRespVo getUserNum(){
        StatementVo users = statementService.getUsers();
        return BaseRespVo.ok(users);
    }

    @RequiresPermissions(value = {"*", "admin:stat:goods"}, logical = Logical.OR)
    @RequestMapping("goods")
    public BaseRespVo getGoodsNum(){
        StatementVo goods = statementService.getGoods();
        return BaseRespVo.ok(goods);
    }
}
